package com.fs.jzzn.pojo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import com.fs.base.param.SysConstant;
import com.fs.base.pojo.PkEntity;

/**
 * @author TiddlerCJ
 * @desc 流程模板及流程节点
 */
@Entity
@Table(name="p_flow")
@NoArgsConstructor
@AllArgsConstructor
@Data@EqualsAndHashCode(callSuper=false) 
public class Flow extends PkEntity{
	private String flowName;//流程名称或节点名称
	private Integer flowOrder;//流程排序
	private String parentId;//父节点
	private String flowCode;//节点编号
	
	@Column(name="active_user_ids", columnDefinition="varchar(500) COMMENT '活动节点处理人id'")
	private String activeUserIds;//活动节点处理人id
	
	@Transient
	private String activeUserNames;	//活动节点处理人姓名

	public String getActiveUserNames() {
	
		StringBuffer sBuffer = new StringBuffer();
		if(getActiveUserIds()!=null){
			for(String id: getActiveUserIds().split(",")){
				if(SysConstant.USERS_ID_NAME_MAP.containsKey(id)){
					sBuffer.append(SysConstant.USERS_ID_NAME_MAP.get(id)).append(",");
				}
			}
			this.activeUserNames = sBuffer.toString();
			if(this.activeUserNames.endsWith(",")){
				this.activeUserNames = this.activeUserNames.substring(0, this.activeUserNames.length()-1);
			}
		}
		return this.activeUserNames;
	}
	
	@Transient
	private Object activeUserJson;	//活动节点处理人姓名
	public Object getActiveUserJson(){
		if(this.activeUserIds==null){
			this.activeUserIds= "";
		}
		activeUserJson = activeUserIds.split(",");
		return activeUserJson;
	}
		
}
